package com.springboot.shiro.service.impl;

import com.springboot.shiro.mapper.UserRoleMapper;
import com.springboot.shiro.pojo.UserRole;
import com.springboot.shiro.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Date: 2019/10/24 16:17
 * @author: ybzhu
 * @Description：
 */
@Service
public class RoleServiceImpl implements RoleService {


    @Autowired
    private UserRoleMapper userRoleMapper;

    /**
     * 添加 权限
     * @param userId
     * @param roleId
     */
    @Override
    public void addPermission(int userId, int roleId) {
        UserRole userRole=new UserRole();
        userRole.setUid(userId);
        userRole.setRoleId(roleId);
        userRoleMapper.insert(userRole);
    }

    /**
     * 删除权限
     * @param userId
     * @param roleId
     */
    @Override
    public void delPermission(int userId, int roleId) {
        userRoleMapper.deleteByUidAndRoleId(userId,roleId);
    }
}
